﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<c:set var="basePath" value="<%=request.getContextPath()%>"/>
	<!-- jsp文件头和头部 -->
	<jsp:include page="../common/common_head.jsp"/>
	<script type="text/javascript" src="${basePath}/js/base/log.js"></script>
	<script type="text/javascript" src="${basePath}/js/base/dialog.js"></script>
	<script type="text/javascript" src="${basePath}/js/sync/sync_list.js"></script>
	<script type="text/javascript" src="${basePath}/js/sync/sync_edit.js"></script>
	
	</head> 
<body>


<div class="container-fluid" style="padding-top: 10px;">
    <div class="panel panel-success">
        <%--<div class="panel panel-default">--%>
        <div class="panel-heading">
            <h3 class="panel-title">syncTrigger 队列</h3>
        </div>
        <div class="panel-body" style="padding-bottom: 0px;">
           <form:form action="${basePath}/sync/findSyncTriggerList.do" method="post" commandName="syncTrigger" id="syncTriggerForm" class="form-horizontal" style="margin-bottom: 0">
            
 
                <input type="hidden" id="templateId" name="templateId">
                <div class="row">
                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="status">状态</label>
                            <div class="col-sm-10">
                                <form:select class="form-control"  path="status" items="${syncStatuMap}" >
                                </form:select>
                            </div>
                        </div>
                    </div>

                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="userName">用户名</label>
                            <div class="col-sm-10">
                                <form:input  path="userName" class="form-control" />
                            </div>
                        </div>
                    </div>

                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="tableName">表名</label>
                            <div class="col-sm-10">
                                <form:input  path ="tableName" class="form-control" />
                            </div>
                        </div>
                    </div>

                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="triggerType">类型</label>
                            <div class="col-sm-10">
                                <form:select class="form-control"  path="triggerType" items="${triggerTypeMap}" >
                                </form:select>         	
                            </div>
                        </div>
                    </div>
                </div>


                <div class="row">
                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="dataSourceId">数据源</label>
                            <div class="col-sm-10">
				                  <form:select class="form-control" path="dataSourceId" items="${dsMap}" >
				                  </form:select>
                                
                            </div>
                        </div>
                    </div>

                  
                  
                  <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="serverName">serverName</label>
                            <div class="col-sm-10">
                                 <form:input  path ="serverName" class="form-control" />
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pLevel">pLevel</label>
                            <div class="col-sm-10">
				                 <form:input  path ="pLevel" class="form-control" />
                                
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pkBegin">pk起始值</label>
                            <div class="col-sm-10">
				                   <form:input  path ="pkBegin" class="form-control" />
                            </div>
                        </div>
                    </div>
                    
                </div>
                
                 <div class="row">
                    <div class="col-xs-3">
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pkValue">pkValue</label>
                            <div class="col-sm-10">
				                  <form:input  path ="pkValue" class="form-control" />
                            </div>
                        </div>
                    </div>
                 </div>
                 
                <div class="row" style="float: right">
                    <div class="col-xs-4">
                        <div class="form-group">
                            <div class="col-sm-3 btn-group" role="group">
                                <form:button type="submit" class="btn btn-success" style="width: 130px;" id=""> 查询</form:button>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-4">
                        <div class="form-group">
                            <div class="col-sm-3 btn-group" role="group">
                                 <a href="javascript:void(0)" onclick="findSyncTriggerById()" style="width: 130px;"  class="btn btn-success" >新增任务</a>	 
                            </div>
                        </div>
                    </div>
					<div class="col-xs-4">
                        <div class="form-group">
                            <div class="col-sm-3 btn-group" role="group">
                                <a href="${basePath}/sync/syncTemplateList.do" style="width: 130px;"  class="btn btn-success" >返回列表</a>	
                            </div>
                        </div>
                    </div>
                </div>
                    
        </form:form>
        </div>
		
       

        <table class="table table-bordered table-hover">
            <thead>
            <tr class="bg-success">
						
						<th>序号</th>
						<th>状态</th>
						<th>数据源</th>
						<th>数据库用户名</th>
						<th>表名</th>
						<th>pkValue</th>
                        <th>batchPkValue</th>
						<th>fieldOne</th>
						<th>fieldTwo</th>
						<th>filedThree</th>
						<th>pLevel</th>
                        <th>triggerType</th>
                        <th>主键起始值</th>
						<th>增量值</th>
						<th>完成数量</th>
						<th>成功数量</th>
						<th>失败数量</th>
						
			</tr>
            </thead>
            <tbody>
           	<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty syncTriggerList}">
						<c:forEach items="${syncTriggerList}" var="syncTrigger" varStatus="vs">
									
							<tr>
								<td>${syncTrigger.triggerId }</td>
								<td>${syncTrigger.status }</td>
								<td>${syncTrigger.dataSourceId }</td>
								<td>${syncTrigger.userName }</td>	
								<td>${syncTrigger.tableName }</td>
								<td>${syncTrigger.pkValue }</td>
                                <td>${syncTrigger.batchPkValue }</td>
                                <td>${syncTrigger.fieldOne }</td>
								<td>${syncTrigger.fieldTwo }</td>
								<td>${syncTrigger.fieldThree }</td>
								<td>${syncTrigger.pLevel }</td>
                                <td>${syncTrigger.triggerType }</td>
                                <td>${syncTrigger.pkBegin }</td>
								<td>${syncTrigger.pkQuantity }</td>
								<td>${syncTrigger.completeCount }</td>
								<td>${syncTrigger.successNum }</td>
								<td>${syncTrigger.failNum }</td>
						</c:forEach>
						
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="10" class="center">没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				
            </tbody>
        </table>

        <div class="panel-footer">
        	
        	<div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
             <div class="pagination" style="margin: 0px">
                
            </div>

            <div class="pagination pull-right" style="margin: 0px">
                
            </div>
            <br/>
            <br/>
        </div>
    </div>

<!-- sync_trigger save -->
<!-- 模态框（Modal） -->
<div class="modal fade" id="modal3" tabindex="-1" role="dialog" aria-labelledby="modal3Label" aria-hidden="true">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">syncTrigger信息</h4>
            </div>
            <div class="modal-body">
			<form action="${basePath}/sync/saveSyncTrigger.do" method="post" id="sync_trigger_form" class="form-horizontal" role="form">
				
				        <div class="form-group">
				            <label class="col-sm-2 control-label " for="templateName">模板名称</label>
                            <div class="col-sm-10">
                                <input  name="templateName"  class="form-control" />
                            </div>
				        </div>
				  
				        <div class="form-group">
                            <label class="col-sm-2 control-label " for="userName">用户名</label>
                            <div class="col-sm-10">
                                <input  name="userName" class="form-control" />
                            </div>
                        </div>
				  
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="tableName">tableName</label>
                            <div class="col-sm-10">
                                <input  name ="tableName" class="form-control" />
                            </div>
                        </div>
				  
					  <div class="form-group">
					    <label for="dataSourceId" class="col-sm-2 control-label">数据源</label>
					    <div class="col-sm-10">
					      <select name="dataSourceId" class="form-control">
					                   <c:forEach items="${dsMap}" var="entry">
					                  		<option value="${entry.key}">${entry.value}</option>
					                  </c:forEach>
					            </select>
					    </div>
					  </div>
					  
					  <div class="form-group">
					    <label for="dataSourceId" class="col-sm-2 control-label">triggerType</label>
					    <div class="col-sm-10">
					      <select name="triggerType" id="triggerType2" class="form-control">
					                   <c:forEach items="${triggerTypeMap}" var="entry">
					                  		<option value="${entry.key}">${entry.value}</option>
					                  </c:forEach>
					            </select>
					    </div>
					  </div>
					  
					  
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="level">level</label>
                            <div class="col-sm-10">
                                <input  name ="pLevel" class="form-control" value="0" />
                            </div>
                        </div>
				  
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="serverName">serverName</label>
                            <div class="col-sm-10">
                                <input  name ="serverName" class="form-control" />
                            </div>
                        </div>

				  

                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="fieldOne">fieldOne</label>
                            <div class="col-sm-10">
                                <input  name ="fieldOne" class="form-control" />
                            </div>
                        </div>

				  

                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="fieldTwo">fieldTwo</label>
                            <div class="col-sm-10">
                                <input  name ="fieldTwo" class="form-control" />
                            </div>
                        </div>

				  

                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="fieldThree">fieldThree</label>
                            <div class="col-sm-10">
                                <input  name ="fieldThree" class="form-control" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pkValue">pkValue</label>
                            <div class="col-sm-10">
				                 <input  name ="pkValue" class="form-control" />    
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pkBegin">主键起始值</label>
                            <div class="col-sm-10">
                                <input  name ="pkBegin" class="form-control" />
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label " for="pkQuantity">增量值</label>
                            <div class="col-sm-10">
                                <input  name ="pkQuantity" class="form-control" />
                            </div>
                        </div>

				  
				</form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<!--                 <button type="submit" class="btn btn-primary">保存</button>
 -->                <a href="javascript:void(0)" onclick="saveSyncTrigger()" class="btn btn-primary">保存</a>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
      
</div>
</body>
</html>
<script type="text/javascript">

$("#templateId").val("${templateId}");

function saveSyncTrigger(){
	
	if(!$.trim($("#triggerType2").val())){
		alert("triggerType 不能为空!");
		return;
	} 
	$("#sync_trigger_form").ajaxSubmit({
		type: 'post',
		url:  '${basePath}/sync/saveSyncTrigger.do',
		dataType:  'json',
		success: function(data) {	
			if(data.success=="true"){
				alert("保存成功!");
				$('#modal3').modal('hide');
				$("#syncTriggerForm").submit();
				//location.href = "${basePath}/sync/findSyncTriggerList.do?templateId="+$("#templateId").val();
			}else{
				if(data.message!=""){
					alert(data.message);
				}else{
					alert("保存失败!");
				}
				
			}
			    
			}
    });
	
}

</script>


